﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ModuleDALCore;
using System.Data;
using DTO;

namespace DAL
{
	public class HESOCONGVIECDAO:DALBase
	{
		public HESOCONGVIECDAO()
		{
			this.OpenConnect();
		}
		private DataTable dt;
		private string _SpName;
		public string SpName
		{
			get { return "SPHESOCONGVIEC"; }
			set { _SpName = value; }
		}
		public DataTable GetListHS(HESOCONGVIEC hs)
		{
			dt = new DataTable();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(hs, null), ConvertClassToArray.GetValues(hs, 0));
				return dt;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list HS"); }
		}
		public List<HESOCONGVIEC> GetListHSs()
		{
			dt = new DataTable();
			List<HESOCONGVIEC> ds = new List<HESOCONGVIEC>();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new HESOCONGVIEC(), null), ConvertClassToArray.GetValues(new HESOCONGVIEC(), 0));
				ds = (List<HESOCONGVIEC>)ConvertDatatableToList.ConvertTo<HESOCONGVIEC>(dt);
				return ds;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list HS"); }
		}
		public String CreatenewId()
		{
			try
			{
				return "HS" + DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(new HESOCONGVIEC(), null), ConvertClassToArray.GetValues(new HESOCONGVIEC(), 1));

			}
			catch { return null; }// throw new InvalidExpressionException("Msg1: Can't Create new HS"); }
		}
		public bool INSERT(HESOCONGVIEC HS)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(HS, null), ConvertClassToArray.GetValues(HS, 2)) == 1);

			}
			catch { return false; }// throw new InvalidExpressionException("Msg1: Can't Insert new HS"); }
		}
		public bool UPDATE(HESOCONGVIEC HS)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(HS, null), ConvertClassToArray.GetValues(HS, 3)) == 1);

			}
			catch { return false; }// throw new InvalidExpressionException("Msg1: Can't Update  HS"); }
		}
		public bool DELETE(HESOCONGVIEC HS)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(HS, null), ConvertClassToArray.GetValues(HS, 4)) == 1);

			}
			catch { return false; }// throw new InvalidExpressionException("Msg1: Can't Delete  HS"); }
		}
		public long GETIDDV(HESOCONGVIEC hs)
		{

			try
			{
				return (long.Parse(DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(hs, null), ConvertClassToArray.GetValues(hs, 5)).ToString()));

			}
			catch { return 0; }// throw new InvalidExpressionException("Msg1: Can't Delete  HS"); }
		}
	}
}
